package ch.kerbtier.malurus.operations;

import ch.kerbtier.malurus.Visitor;
import ch.kerbtier.malurus.Component;
import ch.kerbtier.malurus.CompositeComponent;
import ch.kerbtier.malurus.RequestContext;
import ch.kerbtier.malurus.Updater;

public class UpdateVisitor implements Visitor {
	private Updater updater;
	private RequestContext requestContext;
	
	public UpdateVisitor(Updater updater, RequestContext requestContext){
		this.updater = updater;
		this.requestContext = requestContext;
	}
	
	
	public void visit(Component component) {
		updater.update(component, requestContext);
	}

	public void visit(CompositeComponent compositeComponent) {
		for(Component c:compositeComponent){
			c.acceptVisitor(this);
		}
		updater.update(compositeComponent, requestContext);
	}

}
